import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class ImHeadImageWidget extends StatelessWidget {
  late String url;
  late double width;
  late double height;

  ImHeadImageWidget(this.url, {double width = 40.0, double height = 40.0}) {
    this.width = width;
    this.height = height;
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(1.0),
      child: Container(
        width: width + 1.0,
        height: height + 1.0,
        decoration: BoxDecoration(
            border: Border.all(color: Colors.black26, width: 0.5),
            borderRadius: BorderRadius.circular(25)),
        child: ClipRRect(
          borderRadius: BorderRadius.circular(5),
          child: CachedNetworkImage(
            imageUrl: url,
            width: width,
            height: height,
            fit: BoxFit.fill,
            placeholder: (context, url) =>
                CupertinoActivityIndicator(radius: 10),
            errorWidget: (context, url, error) => Container(
              width: width,
              height: height,
              child: Icon(Icons.error),
            ),
          ),
        ),
/*
        child: ClipOval(
          child: CachedNetworkImage(
            imageUrl: url,
            width: width,
            height: height,
            fit: BoxFit.fill,
            placeholder: (context, url) =>
                CupertinoActivityIndicator(radius: 10),
            errorWidget: (context, url, error) => Icon(Icons.error),
          ),
        ),
*/
      ),
    );
  }
}
